﻿Imports System.Drawing

Public Class Form3
    Private DCT_Block(15, 15) As Long

    Private Sub Form3_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim tifimage As Image = Image.FromFile("D:\Test Projects\New\image compare\I10P10279380-0001.jpg") 'indexed format image.
        Dim NonIndexedImage As New Bitmap(tifimage.Width, tifimage.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)

        Dim g As Graphics = Graphics.FromImage(CType(NonIndexedImage, Image))

        g.DrawImage(tifimage, 0, 0, tifimage.Width, tifimage.Height)
        g.Dispose()
        tifimage.Dispose()


        For ctr = 0 To 1

            Dim processBlockNumber As Integer = 4
            Dim blockCounter As Integer = 1
            For j = 1.5 To (NonIndexedImage.Height / 16) - 1 Step 7
                For i = 1.5 To (NonIndexedImage.Width / 16) - 1 Step 7
                    If blockCounter <= processBlockNumber Then
                        Dim xLine As Integer = 0
                        For xx = 0 + (i * 16) To (15 * 7) + (i * 16)
                            Dim yLine As Integer = 0
                            For yy = 0 + (j * 16) To (15 * 7) + (j * 16)
                                If (xLine = 0 OrElse xLine = (15 * 7)) OrElse (yLine = 0 OrElse yLine = (15 * 7)) Then
                                    NonIndexedImage.SetPixel(xx, yy, Color.Yellow) ' Color.FromArgb(rc, gc, bc))                                    
                                End If
                                yLine += 1
                            Next
                            xLine += 1
                        Next
                    Else
                        NonIndexedImage.Save("D:\Test Projects\New\image compare\xxxI10P10279380-0001.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
                        Me.Close()
                        Exit Sub

                    End If
                    blockCounter += 1
                Next
            Next


        Next
        NonIndexedImage.Save("D:\Test Projects\New\image compare\xxxI10P10279380-0001.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
        Me.Close()
    End Sub
End Class